home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™94 / Talks & Papers / Michael D. Crawford↵ / Word Services SDK 1.0.5 / Writeswell Jr. Source / Options.c < prev    next >
Text File  |  1992-09-25  |  2KB  |  91 lines

  1. /* Options.c
  2.  * Handle options dialog for Writeswell Jr.
  3.  * ©1992 Working Software, Inc.
  4.  * This source code is copyrighted.  Permission is granted to use the Word Services
  5.  * portion of the Writeswell Jr. source code in your own programs, but you 
  6.  * may not distribute the Writeswell Jr. word-processor code as a 
  7.  * commercial product.  If you modify the code, please do not call it 
  8.  * Writeswell Jr. (or Writeswell.)  This will ensure that people understand the 
  9.  * program and don’t have to deal with a number of different versions with 
  10.  * who-knows-what going on in the code.
  11.  * 
  12.  * Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
  13.  * 18 Aug 92 Mike Crawford
  14.  */
  15.  
  16. #include "TBConstants.h"
  17. #include "TBGlobals.h"
  18. #include "OutlineButton.h"
  19. #include "Options.h"
  20. #include "Prefs.h"
  21. #include "Gripe.h"
  22.  
  23. void OptionsDialog( void )
  24. {
  25.     DialogPtr    optDlg;
  26.     short        item;
  27.     short        kind;
  28.     Handle        h;
  29.     Rect        r;
  30.     long        num;
  31.     Boolean        sendByList;
  32.     ControlHandle    listHdl;
  33.     ControlHandle    tblHdl;
  34.     WWJrPrefsHdl    prefHdl;
  35.     
  36.     prefHdl = GetPrefHandle();
  37.     if ( !prefHdl ){
  38.         Gripe( "\pCannot get preferences handle" );
  39.         return;
  40.     }
  41.             
  42.     optDlg = GetNewDialog( rOptionsID, (Ptr)NULL, (WindowPtr)-1 );
  43.     if ( !optDlg )
  44.         return;
  45.  
  46.     GetDItem( optDlg, kODSendText, &kind, &listHdl, &r );
  47.     GetDItem( optDlg, kODSendTable, &kind, &tblHdl, &r );
  48.     
  49.     /* Set up a user proc to draw the default outline */
  50.  
  51.     GetDItem( optDlg, kODDefUser, &kind, &h, &r );
  52.     SetDItem( optDlg, kODDefUser, kind, (Handle)OutlineButton, &r );
  53.     
  54.     sendByList = (*prefHdl)->sendByList;
  55.     
  56.     if ( sendByList )
  57.         SetCtlValue( listHdl, 1 );
  58.     else
  59.         SetCtlValue( tblHdl, 1 );
  60.  
  61.     do {
  62.         ModalDialog( (ProcPtr)NULL, &item );
  63.         
  64.         switch ( item ){
  65.             case kODSendText:
  66.                 sendByList = true;
  67.                 SetCtlValue( listHdl, 1 );
  68.                 SetCtlValue( tblHdl, 0 );
  69.                 break;
  70.             case kODSendTable:
  71.                 sendByList = false;
  72.                 SetCtlValue( listHdl, 0 );
  73.                 SetCtlValue( tblHdl, 1 );
  74.                 break;
  75.         }
  76.     } while ( item != kODCancel && item != kODOk );
  77.     
  78.     if ( item == kODCancel ){
  79.         DisposDialog( optDlg );
  80.         return;
  81.     }
  82.     
  83.     (*prefHdl)->sendByList = sendByList;
  84.  
  85.     ChangedResource( prefHdl );
  86.     WriteResource( prefHdl );
  87.     
  88.     DisposDialog( optDlg );
  89.     
  90.     return;
  91. }